#@layout()


#define content()
<div style="width: 40%;height:270px;" class="easyui-window" title="过期密码修改"
     data-options="collapsible:false,minimizable:false,maximizable:false,closable:false,draggable:false,resizable:false">
    <span style="color:red;margin:35px 15px;padding:20px 0;">#(errorMsg)</span>
    <form id="formId" method="post">
        <input type="hidden" name="user.user_id" id="userId" value="#(user.userId)">
        <table class="table table-bordered">
            <tr>
                <td style="padding-top:15px;">#(_res.get('user.form.oldpassword')):</td>
                <td><input type="text" id="oldPwd" name="oldPwd" class="easyui-passwordbox"
                           data-options="required:true,validType:{length:[6,32]}">
                </td>
            </tr>
            <tr>
                <td style="padding-top:15px;">#(_res.get('user.form.newpassword')):</td>
                <td><input type="text" id="newPwd" name="newPwd" class="easyui-passwordbox"
                           data-options="required:true,validType:{length:[6,32],password:''}">
                </td>
            </tr>
            <tr>
                <td>#(_res.get('user.form.confirmpassword')):</td>
                <td><input type="text" class="easyui-passwordbox" id="confirmPassword" name="confirmPassword"
                           data-options="required:true,validType:{length:[6,32],same:['newPwd'],password:''}">
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <button onclick="updatePassword()" type="button" class="easyui-linkbutton"
                            data-options="iconCls:'icon-application_go'">提交
                    </button>
                </td>
            </tr>
        </table>
    </form>
</div>
#end


#define css()


#end


#define js()

<script type="text/javascript" src="#(ctx)/static/js/crypto-js.js"></script>

<script type="text/javascript">
    function updatePassword() {
        var url = contextRootPath + '/user/updatePwd';

        $('#formId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');

                    $("#oldPwd").passwordbox('setValue', CryptoJS.MD5($("#oldPwd").passwordbox('getValue')).toString());
                    $("#newPwd").passwordbox('setValue', CryptoJS.MD5($("#newPwd").passwordbox('getValue')).toString());
                    $("#confirmPassword").passwordbox('setValue', CryptoJS.MD5($("#confirmPassword").passwordbox('getValue')).toString());
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);
                data = JSON.parse(data);

                if (!data.flag) {
                    $("#oldPwd").passwordbox('setValue', '');
                    $("#newPwd").passwordbox('setValue', '');
                    $("#confirmPassword").passwordbox('setValue', '');
                    $.messager.alert("提示框", data.message, 'info');
                } else {
                    $.messager.alert("提示框", data.message, 'info', function () {
                        location.href = contextRootPath + "/user/login";
                    });
                }


            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

</script>

#end


